﻿Public Class Horarios2

    Public Sub HorasDiariasLunes()
        Dim lunesInicio As TimeSpan = LhiTimeEdit.EditValue
        Dim LunesFinal As TimeSpan = LhfTimeEdit.EditValue
        Dim LunesDesfase As TimeSpan = ldesfase.EditValue
        Dim CalculoLunes As TimeSpan = (LunesFinal - lunesInicio) - LunesDesfase
        HdlTextBox.Text = CalculoLunes.TotalHours
        'MsgBox(n)
    End Sub

    Public Sub HorasDiariasMartes()
        Dim MartesInicio As TimeSpan = MhiTimeEdit.EditValue
        Dim MartesFinal As TimeSpan = MhfTimeEdit.EditValue
        Dim MartesDesfase As TimeSpan = mdesfase.EditValue
        Dim CalculoMartes As TimeSpan = (MartesFinal - MartesInicio) - MartesDesfase
        HdmTextBox.Text = CalculoMartes.TotalHours
        'MsgBox(n)
    End Sub

    Public Sub HorasDiariasMiercoles()
        Dim MiercolesInicio As TimeSpan = MihiTimeEdit.EditValue
        Dim MiercolesFinal As TimeSpan = mihfTimeEdit.EditValue
        Dim MiercolesDesfase As TimeSpan = midesfase.EditValue
        Dim CalculoMiercoles As TimeSpan = (MiercolesFinal - MiercolesInicio) - MiercolesDesfase
   
        HdmiTextBox.Text = CalculoMiercoles.TotalHours
        'MsgBox(n)
    End Sub

    Public Sub HorasDiariasJueves()
        Dim JuevesInicio As TimeSpan = JhiTimeEdit.EditValue
        Dim JuevesFinal As TimeSpan = JhfTimeEdit.EditValue
        Dim JuevesDesfase As TimeSpan = jdesfase.EditValue
        Dim CalculoJueves As TimeSpan = (JuevesFinal - JuevesInicio) - JuevesDesfase
        HdjTextBox.Text = CalculoJueves.TotalHours
        'MsgBox(n)
    End Sub


    Public Sub HorasDiariasViernes()
        Dim ViernesInicio As TimeSpan = VhiTimeEdit.EditValue
        Dim ViernesFinal As TimeSpan = vhfTimeEdit.EditValue
        Dim ViernesDesfase As TimeSpan = vdesfase.EditValue
        Dim CalculoViernes As TimeSpan = (ViernesFinal - ViernesInicio) - ViernesDesfase
        HdvTextBox.Text = CalculoViernes.TotalHours
        'MsgBox(n)
    End Sub

    Public Sub HorasDiariasSabado()
        Dim SabadoInicio As TimeSpan = ShiTimeEdit.EditValue
        Dim SabadoFinal As TimeSpan = ShfTimeEdit.EditValue
        Dim SabadoDesfase As TimeSpan = sdesfase.EditValue
        Dim CalculoSabado As TimeSpan = (SabadoFinal - SabadoInicio) - SabadoDesfase
        HdsTextBox.Text = CalculoSabado.TotalHours
        'MsgBox(n)
    End Sub

    Public Sub HorasDiariasDomingo()
        Dim DomInicio As TimeSpan = DohiTimeEdit.EditValue
        Dim DomFinal As TimeSpan = dohfTimeEdit.EditValue
        Dim DomDesfase As TimeSpan = dodesfase.EditValue
        Dim CalculoDom As TimeSpan = (DomFinal - DomInicio) - DomDesfase
        HddoTextBox.Text = CalculoDom.TotalHours
        'MsgBox(n)
    End Sub


    Public Sub Mostrar()
        If guardar.Enabled = False Then
            guardar.Enabled = True
            cancelar.Enabled = True
            agregar.Enabled = False
            modificar.Enabled = False
            eliminar.Enabled = False
            imprimir.Enabled = False
            PanelArriba.Enabled = True
            PanelAbajo.Enabled = False
        Else
            cancelar.Enabled = False
            guardar.Enabled = False
            agregar.Enabled = True
            modificar.Enabled = True
            eliminar.Enabled = True
            imprimir.Enabled = True
            PanelArriba.Enabled = False
            PanelAbajo.Enabled = True

        End If
    End Sub
    Private Sub Horarios2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.horarios' table. You can move, or remove it, as needed.
        Me.HorariosTableAdapter.Fill(Me.DbFireAndIceDataSet.horarios)
    End Sub

    Private Sub HorariosBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles HorariosBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.HorariosBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbFireAndIceDataSet)

    End Sub

    Private Sub agregar_Click(sender As System.Object, e As System.EventArgs) Handles agregar.Click
        BindingNavigatorAddNewItem.PerformClick()
        Mostrar()
    End Sub

    Private Sub modificar_Click(sender As System.Object, e As System.EventArgs) Handles modificar.Click
        Mostrar()
    End Sub

    Private Sub guardar_Click(sender As System.Object, e As System.EventArgs) Handles guardar.Click
        If DescripcionTextBox.Text.Length = 0 Then
            ErrorProvider1.SetError(DescripcionTextBox, "Debe ingresar una descripción de horario")
        Else
            ErrorProvider1.SetError(DescripcionTextBox, Nothing)
            HorariosBindingNavigatorSaveItem.PerformClick()
            MessageBox.Show("Se guardó el resgistro satisfactoriamente")
            Mostrar()
        End If
    End Sub

    Private Sub cancelar_Click(sender As System.Object, e As System.EventArgs) Handles cancelar.Click
        ErrorProvider1.SetError(DescripcionTextBox, Nothing)
        Mostrar()
        HorariosTableAdapter.Fill(Me.DbFireAndIceDataSet.horarios)
    End Sub
    Private Sub PanelArriba_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles PanelArriba.Paint
        ''SUMA DE HORAS DIARIAS = a semanales
        HorasemanalesTextBox.Text = Val(HdlTextBox.Text) + Val(HdmTextBox.Text) + Val(HdmiTextBox.Text) + Val(HdjTextBox.Text) + Val(HdvTextBox.Text) + Val(HdsTextBox.Text)
    End Sub
    Private Sub SimpleButton1_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
        HorasDiariasLunes()
        HorasDiariasMartes()
        HorasDiariasMiercoles()
        HorasDiariasJueves()
        HorasDiariasViernes()
        HorasDiariasSabado()
        HorasDiariasDomingo()
    End Sub
End Class